﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FoneBuddy.LinqModel.Data;
using System.Net.Mail;

namespace FoneBuddy.LinqModel
{
  public partial  class MailMessage
    {
      public MailMessage()
	{

      }
      #region MailMessage
      public static bool SendMessage(string ToID, string Sub, string strMsg)
      {
          SmtpClient client = new SmtpClient();

          client.DeliveryMethod = SmtpDeliveryMethod.Network;
          // client.EnableSsl = true;
          client.Host = "mail.bhadreshmistry.com";
          client.Port = 25;
          // setup Smtp authentication

          System.Net.NetworkCredential credentials =
              new System.Net.NetworkCredential("inquiry@bhadreshmistry.com", "Bhadresh123#");
          client.UseDefaultCredentials = false;
          client.Credentials = credentials;

          System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
          msg.From = new MailAddress("inquiry@bhadreshmistry.com");
          msg.To.Add(new MailAddress(ToID));

          msg.Subject = Sub;
          msg.IsBodyHtml = true;

          msg.Body = strMsg;
          try
          {
              client.Send(msg);
          }
          catch (Exception ex)
          {
              return false;
          }
          return true;
      }
      #endregion
    }
}
